Skip to content

python-sdk: read pyproject.toml in Dang - #89

Draft
eunomie wants to merge 3 commits into
mainfrom
pyproject-reads-in-dang
Draft

eunomie wants to merge 3 commits into
mainfrom
pyproject-reads-in-dang

Conversation

@eunomie

@eunomie eunomie commented Nov 10, 2026 •

Copy link
Copy Markdown
Member

Reads pyproject.toml with TOML.decode in Dang instead of a withExec of the Go pyproject helper. This covers requires-python, use-uv, base-image, global-client, workspace members, the generated-member marker and the Python floor refusal. The floor now comes from sdk/pyproject.toml instead of a copy in Go. The Go code and tests for these reads are removed.

These stay in Go:

  • set-python-version, set-use-uv and set-base-image. Dang's TOML.encode does not write the bytes go-toml writes: quoting, indentation, blank lines, the trailing newline, and datetimes turned into strings. Moving them would change every file they edit.
  • edit-scope and set-global-client.
  • derive-resources and render-template.

Generation still builds the Go helper, because edit-scope and derive-resources run on every generate.

Known limitation: a pyproject.toml with a nan or inf float anywhere can no longer be read. Dang's TOML.decode converts through JSON, which has no NaN/Inf. Reads that used to succeed now raise: mod config get, the global-client and members reads during generation, and the Python floor refusal. The generated-marker read treats such a file as unmarked, so generation never overwrites or deletes it.

Coverage: the deleted Go unit tests for the Python floor refusal are restored as one e2e check, python-refusal-cases-check. It has the same cases: prereleases, == pins, ranges, ~=, a major-only version, an unreadable pin, a pin overriding requires-python, and the last-release offer only where that release runs.

Unchanged for a symlinked sdk/ or clients/<name>: the old helper got an include-filtered copy that drops a symlinked member, and the new read does not follow symlinks. Either way no generated marker is found, so generation treats the member as the user's and does not replace or delete it.

Checks (rebased onto main after #90, which removed remove-table), run one at a time with dagger check -m .dagger/modules/e2e <name> on CLI and engine v1.0.0-beta.25, all pass:
config-check, python-refusal-cases-check, python-floor-refusal-check, generate-scope-init-check, generate-scope-user-content-check, generate-scope-clients-check, toml-generate-check, generate-scope-global-client-check, generate-scope-global-client-flag-check, generate-scope-existing-check, module-lookup-check, find-client-root-check, cli-sdk-check.
generate-scope-user-content-check gains two regressions: a plain file and a symlink under clients/. Both fail without the fix.
go vet and go test ./... pass in helpers/pyproject.

Timing: config-check on a warm engine with a fresh nonce took 4 s on main and 2 s with this change. Cold timing was not measured.

The pyproject helper built a Go container for every read of a
pyproject.toml. Read the file with TOML.decode instead: requires-python,
use-uv, base-image, global-client, the workspace members and the
generated marker, and the Python floor refusal, which now takes the
floor from sdk/pyproject.toml instead of a copy of it.

A value of another type than the one read stays unset, and a marker
that does not parse reads as no marker, as before.

The set-* commands stay in Go: TOML.encode does not write the bytes
go-toml writes (quoting, indentation, trailing newline, datetimes), so
moving them would change every file they edit.

Signed-off-by: Yves Brissaud <yves@dagger.io>
@eunomie
eunomie force-pushed the pyproject-reads-in-dang branch from 9a9f370 to ebeab1a Compare November 10, 2026 14:12
Every caller passes the file, so its toml takes no default.

Signed-off-by: Yves Brissaud <yves@dagger.io>
The Go helper's tables for the refusal went with its code. Run the same
cases through generation: a .python-version pin, requires-python ranges
and exact pins, prereleases of the floor, unreadable versions, a base
image of the module's own, and the last release offered only to a
Python it runs on. An sdk/ of the user's own stops each case right
after the refusal, so the cases cost no generation.

Signed-off-by: Yves Brissaud <yves@dagger.io>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant